import net.minidev.json.JSONObject;

import java.util.Arrays;
import java.util.List;
import java.util.Set;

/**
 * @Author lzc
 * @Date 2023/7/4 10:37
 */
public class Demo1 {
    public static void main(String[] args) {
        List<String> columns = Arrays.asList(("a,c" + ",op_type").split(","));
        
    
        JSONObject data = new JSONObject();
        data.put("a", 1);
        data.put("b", 2);
        data.put("c", 3);
        data.put("op_type", 3);
        System.out.println(data);
        Set<String> keys = data.keySet();
        
        /*for (String key : keys) {
            if (!columns.contains(key)) {
                keys.remove(key);
            }
        }*/
        /*Iterator<String> it = keys.iterator();
        while (it.hasNext()) {
            String key = it.next();
            if (!columns.contains(key)) {
                it.remove();
            }
        }*/
    
        keys.removeIf(key -> !columns.contains(key));
        
        System.out.println(data);
    
    }
}
